<?php
	/**
	 * c_join controller
	 *
	 * @package application
	 * @subpackage controller
	 * @author con100 <con100@playplus.net>
	 * @since 18/04/2013
	 * @copyright Copyright (c) 2013, PlayPlus
	 **/
	class C_join extends CI_Controller
	{
		// post method value
		var $param = null;

		/**
		 * constructor
		 **/
		public function __construct()
		{
			parent::__construct();
			$this->load->model('m_join');			
		}

		public function index()
		{
			$this->param = $this->input->post();
			
			if (method_exists($this, $this->param['mode'])) {
				$this->{$this->param['mode']}();
			} 
			else {
				show_error('protocol error!');
			}
		}
		/**
		 * @brief join_check_id protocol
		 *
		 * @param post uid User ID
		 * @return 
		 * @author con100 <con100@playplus.net>
		 * @since 05/04/2013
		 * @copyright Copyright (c) 2013, PlayPlus
		 **/
		private function join_check_id()
		{
			if (empty($this->param['uid'])) $this->param['uid'] = null;
			if (empty($this->param['email'])) $this->param['email'] = null;
			if (empty($this->param['location'])) $this->param['location'] = null;
			
			$result = $this->m_join->join_check_id($this->param['user_id']);
			$this->load->view('result_json', $result);
		}
		/**
		 * @brief join_check_nick protocol
		 *
		 * @param post nick User Nick
		 * @return 
		 * @author con100 <con100@playplus.net>
		 * @since 05/04/2013
		 * @copyright Copyright (c) 2013, PlayPlus
		 **/
		private function join_check_nick()
		{
			if (empty($this->param['nick'])) $this->param['nick'] = null;
		
			$result = $this->m_join->join_check_nick($this->param['nick']);
			$this->load->view('result_json', $result);
		}
		/**
		 * @brief join_check_refer protocol
		 *
		 * @param post uid User Id
		 * @param post refer Friend Refer
		 * @return True/False
		 * @author con100 <con100@playplus.net>
		 * @since 05/04/2013
		 * @copyright Copyright (c) 2013, PlayPlus
		 **/
		private function join_check_refer()
		{
			if (empty($this->param['uid'])) $this->param['uid'] = null;
			if (empty($this->param['refer'])) $this->param['refer'] = null;

			$result = $this->m_join->join_check_nick($this->param['uid'],$this->param['refer']);
			$this->load->view('result_json', $result);
		}
		/**
		 * @brief join_check protocol
		 *
		 * @param post uid User ID
		 * @param post upw User Password
		 * @param post nick User Nick
		 * @return True/False
		 * @author con100 <con100@playplus.net>
		 * @since 05/04/2013
		 * @copyright Copyright (c) 2013, PlayPlus
		 **/
		private function join_check()
		{
			if (empty($this->param['uid'])) $this->param['uid'] = null;
			if (empty($this->param['upw'])) $this->param['upw'] = null;
			if (empty($this->param['nick'])) $this->param['nick'] = null;

			$result = $this->m_join->join_check_nick($this->param['uid'],$this->param['upw'],$this->param['nick'] );
			$this->load->view('result_json', $result);
		}

		/**
		 * @brief login protocol
		 *
		 * @param post uid User Id
		 * @param post upw User Password
		 * @return 
		 * @author con100 <con100@playplus.net>
		 * @since 05/04/2013
		 * @copyright Copyright (c) 2013, PlayPlus
		 **/
		private function login($uid, $upw)
		{
			if (empty($this->param['uid'])) $this->param['uid'] = null;
			if (empty($this->param['upw'])) $this->param['upw'] = null;

			$result = $this->m_join->join_check_nick($this->param['uid'],$this->param['upw']);
			$this->load->view('result_json', $result);
		}
	}// END class Common
